package com.library.controller;

import com.library.entity.ReaderType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 至尊伍人组
 * @since 2018-09-30
 */
@Controller
@RequestMapping ( "/readerType" )
public class ReaderTypeController {

    /**
     * 添加一个读者类型
     *
     * @param readerType
     * @return
     */
    @RequestMapping ( "/add" )
    public String add(ReaderType readerType ) {

        //将表单中输入的信息填充到对象中，然后插入到数据库中
        readerType.insert();
        System.out.println(readerType);
        return "redirect:/admin/setting";
    }

    @RequestMapping ( "/del/{readerId}" )
    public String del( @PathVariable int readerId ) {
        //        System.out.println(readerId);

        new ReaderType().deleteById(readerId);

        return "redirect:/admin/setting";

    }

    @RequestMapping ( "/update" )
    public String update( ReaderType readerType ) {
        //        System.out.println(readerType);
        readerType.updateById();

        return "redirect:/admin/setting";
    }

}

